//
//  CYPhoneView.m
//  CreditAddressBook
//
//  Created by Lee on 15/6/9.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYPhoneView.h"
#import "CYDialTool.h"
#import "CYCallCenter.h"

@interface CYPhoneView ()

@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;

@end

@implementation CYPhoneView

- (void)setPhone:(NSString *)phone {
    _phone = phone;
    
    self.phoneLabel.text = phone;
}

+ (instancetype)phoneView {
    CYPhoneView *view = [[[NSBundle mainBundle] loadNibNamed:@"CYPhoneView" owner:nil options:nil] lastObject];
    return view;
}

- (IBAction)callClick:(id)sender {
    [[CYCallCenter sharedCallCenter] callWithNumber:self.phone name:self.name person:self.person success:^{
        CYLog(@"通话成功");
        
        //发送通知更新通讯记录
        [CYNotificationCenter postNotificationName:CYCallStateDisconnectedKey object:nil];
    } failure:^{
        CYLog(@"通话失败");
    }];
}

@end
